﻿@page "/ClearFullCachePage"
@inject FullCahcheServer FullCahcheServer
@using System.ComponentModel
@using AntDesign.TableModels
@using ShanjinPDAUI.ModelEntity
@inject ModalService _modalService
@inject MessageService _message
<h3>清除缓存架信息</h3>
<div>
    <Row>
        <Col Span="24">请选择缓存架</Col>
    </Row>
    <Row>
        <Col Span="24">
        <Select style="width:100%" DataSource="@DataList"
                AllowClear="true"
                ValueOnClear="@(0)"
                @bind-Value="@select"
                ValueName="@nameof(FullCache_Entity.Deviceid)"
                LabelName="@nameof(FullCache_Entity.Remark)">
        </Select>
        </Col>
    </Row>
    <br/>
    <Row>
        <Col Span="24">
        <Button style="width:100%" Type="@ButtonType.Primary" @onclick="@Creat">清除信息</Button>
        </Col>
    </Row>
</div>


@code {
    ObservableCollection<FullCache_Entity> DataList { get; set; } = new ObservableCollection<FullCache_Entity>();
    int select;
    protected override async Task OnInitializedAsync()
    {
        var fullCaches = await FullCahcheServer.GetFullCahes();
        if (fullCaches != null)
        {
            DataList.Clear();
            foreach (var item in fullCaches)
            {
                DataList.Add(item);
            }
        }

        base.OnInitialized();
    }
    private async Task Creat()
    {
        _modalService.Confirm(new ConfirmOptions()
            {
                Title = "提示",
                Icon =@<Icon Type="exclamation-circle" Theme="Outline"></Icon>,
            OkText = "确认",
            OnOk = async (e) =>
            {

                if(select==0) 
                {
                    _message.Info("请选择缓存架");
                }
                var result = await FullCahcheServer.UpdataFullCache(select);

               
                _message.Info(result);
            },
            CancelText = "取消",
            Content = "是否提交？",
        });
    }
}
